package edu.Pta;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Peo p = new Peo("james",36,"man");
        System.out.println("1."+p);
        String str = "hello world!";
        String[] str2 = str.split(" ");
        System.out.println("2."+Arrays.toString(str2));
        //String turn to char[]
        char[] chars = str.toCharArray();
        System.out.println("3."+ Arrays.toString(chars));
        //char[] turn to String
        String str3 = new String(chars);
        System.out.println("4."+str3);
        String str4 = "hello china!";
        System.out.println("5."+str3.concat(str4));
        char c = str4.charAt(0);
        System.out.println(c);
        int i1 = str4.indexOf("china");
        System.out.println(i1);
        int i2 = str4.indexOf("l");
        int i3 = str4.lastIndexOf("l");
        System.out.println(i2+" "+i3);
        System.out.println(str4.startsWith("hello"));
        System.out.println(str4.endsWith("china!"));
        System.out.println();
        testlem testlem = (x,y)->{
            return x+y;
        };
        System.out.println(testlem.add(2,3));
        int[] arr = {52,65,45,25,95};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-i-1; j++) {
                if(arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        for (int a:arr) {
            System.out.println(a);
        }

    }
}
interface testlem{
    int add(int x,int y);
}
class Peo{
    private String name;
    private int age;
    private String sex;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Peo() {
        super();
    }

    public Peo(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Peo{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }
}
